export function getLocation() {
    var options = {
        enableHighAccuracy: true,
        maximumAge: 1000,
    }
    if (!navigator.geolocation) {
        //浏览器不支持geolocation
        alert('浏览器不支持geolocation')
        return
    }

    navigator.geolocation.getCurrentPosition(
        onSuccess,
        onError,
        options
    );
}
function onSuccess(position) {
    let address = {
        latitude: position.coords.latitude,
        longitude: position.coords.longitude
    }
    window.localStorage.setItem('address', JSON.stringify(address))
}
function onError(error) {
    switch (error.code) {
        case 1:
            window.localStorage.setItem('address', '位置服务被拒绝')
            break

        case 2:
            window.localStorage.setItem('address', '暂时获取不到位置信息')
            break

        case 3:
            window.localStorage.setItem('address', '获取信息超时')
            break

        case 4:
            window.localStorage.setItem('address', '未知错误')
            break
    }
}


  // 手机im信息
//   var canvas = document.createElement('canvas'),
//     gl = canvas.getContext('experimental-webgl'),
//     debugInfo = gl.getExtension('WEBGL_debug_renderer_info')
//   alert(gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL))